/*
 * @Author: 吴世扬 18368095041@163.com
 * @Date: 2025-02-18 08:36:31
 * @LastEditors: 吴世扬 18368095041@163.com
 * @LastEditTime: 2025-02-21 08:29:22
 * @FilePath: /vue3-admin-server/src/entities/role.entity.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */

import { Entity, Column, ManyToMany, JoinTable } from 'typeorm';
import { BaseEntity } from './base.entity';
import { MenuEntity } from './menu.entity';

@Entity({
    name: 'role'
})
export class RoleEntity extends BaseEntity {
    @Column({ length: 64 })
    name: string;

    @Column({ length: 255 })
    description: string;

    @ManyToMany(() => MenuEntity)
    @JoinTable({
        name: 'role_menu',
        joinColumn: {
            name: 'role_id',
            referencedColumnName: 'id'
        },
        inverseJoinColumn: {
            name: 'menu_id',
            referencedColumnName: 'id'
        }
    })
    menus: MenuEntity[];
}
